<template>
	<view class="ground" :style="{backgroundImage:`url(${$ossUrl + 	open_creen_img})`}">
		<view class="time" @click="goIndex">{{ time }}s 跳过</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: 5,
				timer: ''
			};
		},
		methods: {
			goIndex() {
				clearInterval(this.timer);
				uni.setStorageSync('isOpenCreen', 1)
				uni.switchTab({
					url: '/pages/index/index'
				});
			}
		},
		onLoad() {
			this.timer = setInterval(() => {
				this.time -= 1;
				if (this.time == 0) {
					clearInterval(this.timer);
					this.goIndex();
				}
			}, 1000);
		},
		computed: {
			open_creen_img() {
				const imgArr = this.appConfig.open_creen_img.split(',')
				let now = new Date();
				let hour = now.getHours();
				if (hour >= 8 && hour < 18) {
					return imgArr[0]
				} else {
					return imgArr[1]
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ground {
		width: 100%;
		height: 100vh;
		background-size: cover;
		// background-position: center;
		position: relative;

		.time {
			position: absolute;
			right: 16rpx;
			top: 90rpx;
			padding: 4rpx;
			border-radius: 8rpx;
			background: rgba(0, 0, 0, 0.6);
			color: #fff;
			font-size: 24rpx;
		}
	}
</style>